<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Api_Model_UserLocation
{
	private $user_location_id;
	private $user_id;
	private $longitude;
	private $latitude;
	private $send_time;

	public function __construct($userlocation_row = null) {
		if(!is_null($userlocation_row) && $userlocation_row instanceof Zend_Db_Table_Row) {
			$this->user_location_id = $userlocation_row->user_location_id;
			$this->user_id = $userlocation_row->user_id;
			$this->longitude = $userlocation_row->longitude;
			$this->latitude = $userlocation_row->latitude;
			$this->send_time = $userlocation_row->send_time;
		}
	}

	public function __set($name, $value) {
		switch($name) {
			case 'user_location_id':
				if(!is_null($this->user_location_id)) {
					throw new Exception('Cannot update user location\'s id');
				}
				break;
			case 'user_id':
				if(!is_null($this->user_id)) {
					throw new Exception('Cannot update travel user\'s id');
				}
				break;
			case 'longitude':
				if(!is_null($this->longitude)) {
					throw new Exception('Cannot update longitude');
				}
				break;
			case 'latitude':
				if(!is_null($this->latitude)) {
					throw new Exception('Cannot update latitude');
				}
				break;
			case 'send_time':
				if(!is_null($this->send_time)) {
					throw new Exception('Cannot update send_time');
				}
				break;
		}
		$this->$name = $value;
	}

	public function __get($name) {
		return $this->$name;
	}
}
